import request, { type ListResponse, type ListQuery } from "@/utils/request";
import { type TaskType } from "./task";

const BASE_URL = "/api/internal/webHook/tasklog";

export const TaskLogAPI = {
  getTaskLogList: (params: ListQuery) => {
    return request.get<any, ListResponse<TaskLogType>>(`${BASE_URL}/`, {
      params,
    });
  },
  getTaskLogDetail: (id: number) => {
    return request.get<any, TaskLogType>(`${BASE_URL}/${id}/`);
  },
  updateTaskLog: (data: Partial<TaskLogType>) => {
    return request.put(`${BASE_URL}/${data.id}/`, data);
  },
  deleteTaskLog: (id: number) => {
    return request.delete(`${BASE_URL}/${id}/`);
  },
};

export type TaskLogListQuery = {} & ListQuery;

export type TaskLogType = {
  id: number;
  task: TaskType;
  message: string;
  response_status: number;
  response_error: string;
  response_text: string;
  created_at: string;
  target_url: string;
};

export default TaskLogAPI;
